import {BrowserWindow} from "electron";
import {createProtocol} from "vue-cli-plugin-electron-builder/lib";

class AppWindow extends BrowserWindow {
    constructor(config, fileLocation,debug=true) {
        const basicConfig = {
            title:'',
            width: 800,
            height: 700,
            show: false,
            frame: true,
            movable:true,
            focusable:true,
            resizable:false,
            titleBarStyle:"hiddenInset",
            webPreferences: {
                enableRemoteModule:true,
                nodeIntegration: true,
                contextIsolation: false,
                webSecurity: false
            }
        }
        super({...basicConfig, ...config});
        if(process.env.NODE_ENV === 'production'){
            createProtocol('app')
        }
        this.loadURL(fileLocation).then(r => {})
        this.once('ready-to-show', () => {
            this.show()
        })
        debug && this.webContents.openDevTools()
    }
}

export default AppWindow
